<?=$this->header()?>


    <?=$this->menu("content")?>


    <h1><?=$this->message("label.links", _Content::BUNDLE)?></h1>


    <? /* Breadcrums route & user info display */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.category.header", _Content::BUNDLE),
                "href"=>"content/category/index"
            ),
            array(
                "name"=>$this->category($this->contentLinks($this->linkListForm)->getContentI18n()->getContent()->getCategoryId()),
                "href"=>"content/index"
            ),
            array(
                "name"=>$this->message("label.links.for", _Content::BUNDLE) . " \"" .
                    $this->contentLinks($this->linkListForm)->getContentI18n()->getName() ."\""
            )
        ),                                                   // Route display
        $this->linkListForm,                                 // ListForm (for user info, see float right)
        $this->contentLinks($this->linkListForm)->getRows()) // The total amount of links
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->linkListForm)?>"
          method="post"
          action="content/link/index"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "content/link/edit?contentLink->contentId=" . $this->linkListForm->getId(), // Add new URL
            $this->linkListForm, // ListForm
            array(                // Filter fields
                ContentLinkPeer::NAME=>$this->message("prompt.link.name", _Content::BUNDLE),
                ContentLinkPeer::LINK=>$this->message("prompt.link.url", _Content::BUNDLE),
                ContentLinkPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                ContentLinkPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                ContentLinkPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th>
                <?=$this->TH(
                    $this->linkListForm,                                // ListForm
                    ContentLinkPeer::NAME,                              // Sort Field
                    $this->message("prompt.link.name", _Content::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->linkListForm,                             // ListForm
                    ContentLinkPeer::MODIFIED_DATE,                  // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->linkListForm,                            // ListForm
                    ContentLinkPeer::INSERT_DATE,                   // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->linkListForm,                          // ListForm
                    ContentLinkPeer::ACTIVE,                      // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.order", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->linkListForm,                          // ListForm
                    ContentLinkPeer::POSITION,                    // Sort Field
                    $this->message("label.order", _Core::BUNDLE), // Header Name
                    "ASC"
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->contentLinks($this->linkListForm)->getItems() as $link) { ?>

            <? /* Display the default language content */ ?>
            <tr class="ctrl">
                <td class="checkbox">

                    <input type="checkbox"
                           name="items[]"
                           value="<?=$link->getContentLinkId()?>"
                           <?=in_array($link->getContentLinkId(), $this->linkListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td><?=$this->truncateNicely($link->getName(), 70, 80, "...")?></td>
                <td class="buttons" title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$link->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$link->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td class="buttons" title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$link->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$link->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($link->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td title="<?=$this->message("title.move", _Core::BUNDLE)?>">

                    <? if($link->getPosition() > 1): ?>
                        <input type="image" onclick="moveup(<?=$link->getContentLinkId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_up.png")?>" alt=""
                               alt="<?=$this->message("title.move.up", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.up", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                    <? if($link->getPosition() < $link->getMaxPosition()): ?>
                        <input type="image" onclick="movedown(<?=$link->getContentLinkId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_down.png")?>"
                               alt="<?=$this->message("title.move.down", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.down", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('content/link/edit?contentLink->contentLinkId=<?=$link->getContentLinkId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$link->getContentLinkId()?>, '<?=get_class($this->linkListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->linkListForm,  // ListForm
            array(                // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->linkListForm,                                                        // ListForm
            "content/link/edit?contentLink->contentId=" . $this->linkListForm->getId(), // Add new URL
            $this->contentLinks($this->linkListForm)->getRows()                         // The total amount of users
        )?>


    </form>

<?=$this->footer()?>